nl.telin.mymedia.analysis.infgain
Class SparseVector<K extends java.lang.Number>

java.lang.Object
  extended by nl.telin.mymedia.analysis.infgain.SparseVector<K>
All Implemented Interfaces:
java.io.Serializable

public class SparseVector<K extends java.lang.Number>
extends java.lang.Object
implements java.io.Serializable

The SparseVector is a indexed vector where 0 values have been removed.

See Also:
Serialized Form

Constructor Summary
SparseVector()
          Constructor, initializes size to 0
 
Method Summary
 java.lang.Float addTo(int position, java.lang.Float a)
          add value to existing value at indexed position
 java.lang.Integer addTo(int position, java.lang.Integer a)
          add value to existing value at indexed position
 void divideElementsBy(float fraction)
          divide existing values by a certain value
 void divideElementsBy(int fraction)
          divide existing values by a certain value
 java.lang.Float getFloatAt(int position)
          get Flaot value from position
 java.lang.Integer getIntegerAt(int position)
          get Integer value from position
 java.util.Iterator<java.lang.Integer> getKeyIterator()
           
 int getNrOfNonZeroValues()
           
 int getSize()
           
 void positiveDiff(SparseVector<java.lang.Float> distr)
          remove values that have a negative difference with provided distr.
 boolean setAt(int position, K value)
          set value at indexed position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseVector

public SparseVector()
Constructor, initializes size to 0

Method Detail

getSize

public int getSize()
Returns:
the size of this vector

getNrOfNonZeroValues

public int getNrOfNonZeroValues()
Returns:
the number of non-zero values

setAt

public boolean setAt(int position,
                     K value)
set value at indexed position

Parameters:
position - the position
value - the value
Returns:
true

getFloatAt

public java.lang.Float getFloatAt(int position)
get Flaot value from position

Parameters:
position - the position
Returns:
Float value

getIntegerAt

public java.lang.Integer getIntegerAt(int position)
get Integer value from position

Parameters:
position - the position
Returns:
Integer value

addTo

public java.lang.Float addTo(int position,
                             java.lang.Float a)
add value to existing value at indexed position

Parameters:
position - the position
a - the value to be added
Returns:
the added value

addTo

public java.lang.Integer addTo(int position,
                               java.lang.Integer a)
add value to existing value at indexed position

Parameters:
position - the position
a - the value to be added
Returns:
the added value

getKeyIterator

public java.util.Iterator<java.lang.Integer> getKeyIterator()

divideElementsBy

public void divideElementsBy(int fraction)
divide existing values by a certain value

Parameters:
fraction - the divider

divideElementsBy

public void divideElementsBy(float fraction)
divide existing values by a certain value

Parameters:
fraction - the divider

positiveDiff

public void positiveDiff(SparseVector<java.lang.Float> distr)
remove values that have a negative difference with provided distr. remaining items are divided by sum difference.

Parameters:
distr - the distribution to compare to.